import http from "@/http";
import { User, UserListParm, Login, AssignParm, UpdatePasswordParm } from "./UserModel";

//新增
export const addApi = (parm: User) => {
    return http.post("/api/user", parm)
}

//列表
export const getListApi = (parm: UserListParm) => {
    return http.get("/api/user/list", parm)
}

//根据用户id查询角色
export const getRoleListApi = (userId: string) => {
    return http.get("/api/user/getRoleList", { userId: userId })
}

//编辑
export const editApi = (parm: User) => {
    return http.put("/api/user", parm)
}

//删除
export const deleteApi = (userId: string) => {
    return http.delete(`/api/user/${userId}`)
}

//重置密码
export const resetPasswordApi = (parm: { userId: string }) => {
    return http.post("/api/user/resetPassword", parm)
}

//验证码
export const getImgApi = () => {
    return http.post("/api/user/getImage")
}

//登录
export const loginApi = (parm: Login) => {
    return http.post("/api/user/login", parm)
}

//查询菜单树
export const getAssignTreeApi = (parm: AssignParm) => {
    return http.get("/api/user/getAssignTree", parm)
}

//修改密码
export const updatePasswordApi = (parm: UpdatePasswordParm) => {
    return http.post("/api/user/updatePassword", parm)
}

//退出登录
export const loginOutApi = () => {
    return http.post("/api/user/loginOut")
} 

//获取用户信息
export const getInfoApi = (userId:string)=>{
    return http.get("/api/user/getInfo",{userId:userId})
}